package com.company.kotlinlearn

import android.os.Bundle
import android.view.View
import android.widget.TextView
import android.widget.Toast
import androidx.appcompat.app.AppCompatActivity
import androidx.databinding.DataBindingUtil
import com.company.kotlinlearn.bean.Person
import com.company.kotlinlearn.databinding.ActivityDataBindingBindingImpl


class DataBindingActivity : AppCompatActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        val dataBinding: ActivityDataBindingBindingImpl =
            DataBindingUtil.setContentView<ActivityDataBindingBindingImpl>(
                this,
                R.layout.activity_data_binding
            )
        dataBinding.listener = EventListener()
        val person = Person("jany", 18)
        dataBinding.apply {
            name = person.toString()
        }
        var textTv: TextView = findViewById(R.id.text)
//        textTv.setOnClickListener {
//            if (it.visibility != View.INVISIBLE) {
//                it.visibility = View.INVISIBLE
//                it.isEnabled = true
//            }
//            else {
//                it.visibility = View.VISIBLE
//            }
//        }


    }

    inner class EventListener {
        fun onClick(view: View) {
            Toast.makeText(this@DataBindingActivity, "点击按钮", Toast.LENGTH_SHORT).show()
        }
    }
}